<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      v-show="showSearch"
      :inline="true"
    >
      <el-form-item label="商品编码" prop="ref">
        <el-input
          v-model="queryParams.ref"
          style="width: 205px"
          placeholder="请输入"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品型号" prop="model">
        <el-input
          v-model="queryParams.model"
          placeholder="请输入"
          style="width: 230px"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="回收编码" prop="recycleCode">
        <el-input
          v-model="queryParams.recycleCode"
          placeholder="请输入"
          style="width: 230px"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="Search"
          @click="handleQuery"
          v-hasPermi="['erp:system:log:list']"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="dataList">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="商品型号" prop="model" align="center" />
      <el-table-column label="商品编码" prop="ref" align="center" />
      <el-table-column label="回收编码" prop="recycleCode" align="center" />
      <el-table-column
        label="商品正面图"
        prop="watchImageUrl"
        align="center"
        width="110"
      >
        <template #default="scope">
          <div style="display: flex; align-items: center; width: 50px">
            <el-image
              :src="scope.row.watchImageUrl"
              :preview-src-list="[scope.row.watchImageUrl]"
              preview-teleported
            />
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="商品背面图"
        prop="watchImageUrlBack"
        align="center"
        width="110"
      >
        <template #default="scope">
          <div style="display: flex; align-items: center; width: 50px">
            <el-image
              :src="scope.row.watchImageUrlBack"
              :preview-src-list="[scope.row.watchImageUrlBack]"
              preview-teleported
            />
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作人" prop="operationName" align="center" />
      <el-table-column label="操作时间" prop="operationTime" align="center" />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<script setup name="Log">
import { listTable } from "@/api/system/log";
const { proxy } = getCurrentInstance();
const dataList = ref([]);
const total = ref(0);
const loading = ref(true);
const showSearch = ref(true);

const queryParams = ref({
  pageNum: 1,
  pageSize: 10,
  model: undefined,
  ref: undefined,
  recycleCode: undefined
});
/** 查询列表 */
function getList() {
  listTable(queryParams.value).then((response) => {
    dataList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.pageNum = 1;
  getList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}
getList();
</script>
